import pymysql
import pandas as pd

def get(sql):
    db_connect_middle = pymysql.connect(host='localhost',
                                        port=3306,
                                        user='root',
                                        password='',
                                        database='test',
                                        charset="utf8",
                                        cursorclass=pymysql.cursors.DictCursor)
    cursor_middle = db_connect_middle.cursor()
    result = pd.read_sql(sql=sql, con=db_connect_middle)
    cursor_middle.close()
    db_connect_middle.close()
    print(result)
    return result

sql='''
select * from user

'''
result=get(sql)
print(type(result))

print(result.get(0)['name'])

